<?php
#
# author: Cody Sorgenfrey
# (c)2012 South Hill Calvary Chapel
#

include_once("../mysql/database_info.php");
include_once("common.php");
include_once("../mysql/common.php");

function personBackView($person){
	
	$id=$person['id'];
	$position=$person["position"];
	$first=$person["first"];
	$last=$person["last"];
	$name = $first." ".$last;
	$phone=$person["phone"];
	$email=$person["email"];
	$website=$person["website"];
	$facebook=$person["facebook"];
	$blog=$person["blog"];
	$book=$person["book"];
	$verse=$person["verse"];
	$scripture=$person["scripture"];
	$picture=$person["picture"];
	$picture2=$person["picture2"];
	$par[0]=$person["par1"];
	$par[1]=$person["par2"];
	$par[2]=$person["par3"];
	$par[3]=$person["par4"];
	
	$num_par=count($par);
	
	printf("<div class='moreInfoBack' id='back%s'>", $id);	
	printf("<div style='width:%s; text-align:right;'><p onclick='showMore(\"%s\")'>[Read Less]</div>\n", "100%", $person['id']);	
	printf("<div style='width:%s; text-align:center;'>\n", "100%");
	if (!empty($picture2)) {
		printf("<img id='staff' src='%s'></img>\n", $picture2);
	} else {
		printf("<img id='staff' src='%s'></img>\n", $picture);
	}
	printf("\t</div>\n");
	
	printf("\t<div class=paragraph>\n");
	printf("\t\t<strong><i>%s</i></strong> - %s %s\n",$scripture, $book, $verse);
	printf("\t</div>\n");
	
	
	for ($i=0; $i<$num_par; $i++) {
		if (empty($par[$i])) {
			continue;
		}
		printf("\t<div class=paragraph>\n");
		printf("\t\t<p>%s</p>\n", $par[$i]);
		printf("\t</div>\n");
	}
	printf("\t<h4>\n");
	printf("\t\tMore...\n");
	printf("\t</h4>\n");
	printf("\t<div class='paragraph'>\n");
	printf("\t\t<ul>\n");
	printf("\t\t\t<li><a href='mailto:%s'><p>%s</p></a></li>\n", $email, $email);
	if (!empty($facebook)) {
		printf("\t\t\t<li><a href='%s' target='_blank'><img src='http://www.southhillcalvary.org/images/facebook_35x35.png' width='20' height='20'/> Facebook</a></li>\n", $facebook);
	}
	if (!empty($website)) {
		printf("\t\t\t<li><a href='%s' target='_blank'>Website</a></li>\n", $website);
	}
	if (!empty($blog)) {
		printf("\t\t\t<li><a href='%s' target='_blank'><img src='http://www.southhillcalvary.org/images/wp_35x35.png' width='20' height='20'\> Blog</a></li>\n", $blog);
	}
	printf("\t\t</ul>\n");
	printf("\t</div>\n");
	printf("</div>\n");
	printf("</div>");
}

function people($person) {
	
	printf("<div class='infoCard' id='infoCard%s'>\n", $person['id']);
	printf("<div class='moreInfoFront' id='front%s'>\n", $person['id']);
	printf("<table class='std'>\n");
	$position=$person["position"];
	$first=$person["first"];
	$last=$person["last"];
	$phone=$person["phone"];
	$email=$person["email"];
	$picture=$person["picture"];
	$par1=$person["par1"];
	$name = $first." ".$last;
	printf("\t<tr>\n");
	printf("\t\t<td width='30px'>\n");
	if (!empty($par1)) {
		$id=$person["id"];
		printf("\t\t<td width='288px'>\n");
		printf("<span onclick='showMore(\"%s\")'><img id='staff' src='%s'></span>\n", $id, $picture);
		printf("</td>\n", $picture);
	} else {
		printf("\t\t<td width='288px'><img id='staff' src='%s'></td>\n", $picture);
	}
	printf("\t\t<td width='30px'>&nbsp</td>\n");
	printf("\t\t<td align='left'>\n");
	printf("\t\t\t<TABLE class='std'>\n");
	printf("\t\t\t\t<tr><td><strong>%s</strong></td></tr>\n",$name);
	printf("\t\t\t\t<tr><td>%s</td></tr>\n",$position);
	printf("\t\t\t\t<tr><td><a href='mailto:%s'><p>%s</p></a></td></tr>\n",
	        $email, $email);
	printf("\t\t\t\t<tr><td>%s</td></tr>\n",$phone);
	if (!empty($par1)) {
		printf("\t\t\t\t<tr><td><br/><span onclick='showMore(\"%s\")'>[Read More]</span></td></tr>\n",$id);
	}
	printf("\t\t\t</table>\n");
	printf("\t\t</td>\n");
	printf("\t<tr><td colspan='3'>&nbsp</td></tr>\n");
	printf("</table>\n");
	printf("</div>\n");
	
	personBackView($person);
}

$table = "people";
connect_select_test($table);
$title = "Meet the Leadership";
$meta_key='leadership, meet, office, pastors, chaplains, elders';
$meta_desc="Meet the South Hill Calvary Chapel leadership.";
$query="SELECT * FROM $table WHERE leader='1' ORDER BY display_order ASC";
$morehtml= null;
$morejava= null;

startPageNoPageContent($title, $meta_key, $meta_desc, $morehtml, $morejava);
$result=mysql_query($query) or die (mysql_error());
while ($person = mysql_fetch_array($result)){
	people($person);
}
mysql_close();
endPageNoContent();
?>